package com.chen.pfm.entity;

import com.chen.pfm.utils.AccountDBUtil;
import com.chen.pfm.utils.DateUtils;
import com.chen.pfm.utils.StatementsDBUtil;
import ohos.aafwk.ability.DataAbilityRemoteException;
import ohos.app.Context;

import java.io.Serializable;

//保存页面跳转的传递对象，渲染页面
public class StatisticsInfo implements Serializable {
    // 标准序列ID, 用于判断版本
    private static final long serialVersionUID = 1L;

    double stodaySpending = 0.0;
    double stodayIncome = 0.0;
    double spastSevenDaysSpending = 0.0;
    double spastSevenDaysIncome = 0.0;
    double sMonthSpending = 0.0;
    double sMonthIncome = 0.0;
    double sYearSpending = 0.0;
    double sYearIncome = 0.0;
    double sCurrentMonthBudget = 0.0;

    public StatisticsInfo() {
    }

    public double getStodaySpending() {
        return stodaySpending;
    }

    public void statistics(Context context) {
        String strCurrentYearandMonth = DateUtils.getStrCurrentYearandMonth();
        String currentYearandMonthandDay = DateUtils.getStrCurrentYearandMonthandDay();
        String strCurrentYear = DateUtils.getStrCurrentYear();
        try {
            //首页上部分背景
            stodaySpending = AccountDBUtil.statisticsMoneyByArtimeAndtype1(context, currentYearandMonthandDay, 1);
            stodayIncome = AccountDBUtil.statisticsMoneyByArtimeAndtype1(context, currentYearandMonthandDay, 2);
            spastSevenDaysSpending = AccountDBUtil.statisticalMoneyPastSevenDaysBytype1(context, 1);
            spastSevenDaysIncome = AccountDBUtil.statisticalMoneyPastSevenDaysBytype1(context, 2);
            sMonthSpending = AccountDBUtil.statisticsMoneyByArtimeAndtype1(context, strCurrentYearandMonth, 1);
            sMonthIncome = AccountDBUtil.statisticsMoneyByArtimeAndtype1(context, strCurrentYearandMonth, 2);
            sYearSpending = AccountDBUtil.statisticsMoneyByArtimeAndtype1(context, strCurrentYear, 1);
            sYearIncome = AccountDBUtil.statisticsMoneyByArtimeAndtype1(context, strCurrentYear, 2);


        } catch (DataAbilityRemoteException e) {
            e.printStackTrace();
        }
    }

    public double getsCurrentMonthBudget() {
        return sCurrentMonthBudget;
    }

    public void setsCurrentMonthBudget(Context context, int uid) {
        this.sCurrentMonthBudget = StatementsDBUtil.statisticsCurrentMonthBudgetByUid(context, uid);
        ;
    }


    @Override
    public String toString() {
        return "StatisticsInfo{" +
                "stodaySpending=" + stodaySpending +
                ", stodayIncome=" + stodayIncome +
                ", spastSevenDaysSpending=" + spastSevenDaysSpending +
                ", spastSevenDaysIncome=" + spastSevenDaysIncome +
                ", sMonthSpending=" + sMonthSpending +
                ", sMonthIncome=" + sMonthIncome +
                ", sYearSpending=" + sYearSpending +
                ", sYearIncome=" + sYearIncome +
                ", sCurrentMonthBudget=" + sCurrentMonthBudget +
                '}';
    }

    public double getRemainingBudget() {
        return sCurrentMonthBudget - sMonthSpending;
    }

    public double getMonthbalance() {
        return sMonthSpending - sMonthIncome;
    }

    public double getStodayIncome() {
        return stodayIncome;
    }

    public double getSpastSevenDaysSpending() {
        return spastSevenDaysSpending;
    }

    public double getSpastSevenDaysIncome() {
        return spastSevenDaysIncome;
    }

    public double getsMonthSpending() {
        return sMonthSpending;
    }

    public double getsMonthIncome() {
        return sMonthIncome;
    }

    public double getsYearSpending() {
        return sYearSpending;
    }

    public double getsYearIncome() {
        return sYearIncome;
    }
}
